package day15.ZiXi;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorDemo02 {
    public static void main(String[] args) {
        //核心线程数量为1 ， 最大线程池数量为3, 任务容器的容量为1 ,空闲线程的最大存在时间为20s
        ThreadPoolExecutor threadPoolExecutor;
        threadPoolExecutor = new ThreadPoolExecutor(1 , 3 , 20 , TimeUnit.SECONDS ,
                new ArrayBlockingQueue<>(1) , Executors.defaultThreadFactory() , new ThreadPoolExecutor.DiscardOldestPolicy());
        for (int x = 0; x <5; x++) {
            //final int y = x ;
            threadPoolExecutor.submit(()->{
                System.out.println(Thread.currentThread().getName()+"===>zx");
            });
            //System.out.println(Thread.currentThread().getName()+"===>zx"+ y);
        //});
            
        }
    }
}
